The main structural stiffness is provide by the top and lower flanges, one in compression the other in tension, being separated by the web.
Seperating these two, gains a mechanical advantage. The tensional and compressive forces are increased for the same deflection.
A shear force can be imagined as a cutting force.
H beams have a larger cross section than a similar size I beam and hence more resistance to a cutting action.